package cn.forkway.learn.jdbcTry;

import cn.forkway.learn.jdbcTry.utils.DBUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @program: java-learn-jdbc
 * @className: demo05.java
 * @author: River Ray
 * @description: test DBUtis
 * @createTime 2021年10月08日 20:12:00
 */
public class demo05 {
    public static void main(String[] args) {
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        try {
            conn = DBUtil.getConnection();
            String sql = "select * from t_user";
            ps = conn.prepareStatement(sql);
            rs = ps.executeQuery();
            while (rs.next()) {
                System.out.println(rs.getString("loginName")+rs.getString("loginPwd"));
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } finally {
            DBUtil.close(conn, ps, rs);
        }
    }
}
